import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import { App, Component } from 'vue'

import SvgIcon from './SvgIcon.vue'
import CategorySearch from './CategorySearch.vue'
import WuTable from './WuTable.vue'

interface GlobalComponents {
  [key: string]: Component
}

const allGlobalComponents: GlobalComponents[] = [
  SvgIcon,
  CategorySearch,
  WuTable
]
export default {
  install(app: App) {
    // 注册本地svg为全局组件
    Object.keys(allGlobalComponents).forEach((key: string) => {
      app.component(key, allGlobalComponents[key as any])
    })
    // element-plus-icons全局注册
    for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
      app.component(key, component)
    }
  }
}
